home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / tcl / tcl70b2.lha / tcl7.0b2 / tclAppInit.c < prev    next >
C/C++ Source or Header  |  1993-07-01  |  3KB  |  92 lines

  1. /* 
  2.  * tclAppInit.c --
  3.  *
  4.  *    Provides a default version of the Tcl_AppInit procedure.
  5.  *
  6.  * Copyright (c) 1993 The Regents of the University of California.
  7.  * All rights reserved.
  8.  *
  9.  * Permission is hereby granted, without written agreement and without
  10.  * license or royalty fees, to use, copy, modify, and distribute this
  11.  * software and its documentation for any purpose, provided that the
  12.  * above copyright notice and the following two paragraphs appear in
  13.  * all copies of this software.
  14.  * 
  15.  * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
  16.  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
  17.  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  18.  * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  19.  *
  20.  * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  21.  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  22.  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  23.  * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  24.  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  25.  */
  26.  
  27. #ifndef lint
  28. static char rcsid[] = "$Header: /user6/ouster/tcl/RCS/tclAppInit.c,v 1.3 93/07/01 15:16:08 ouster Exp $ SPRITE (Berkeley)";
  29. #endif /* not lint */
  30.  
  31. #include "tcl.h"
  32.  
  33. /*
  34.  * The variable below holds a startup script to be executed at the
  35.  * beginning of the application.
  36.  */
  37.  
  38. char initCmd[] =
  39. "if [file exists [info library]/init.tcl] {\n\
  40.     source [info library]/init.tcl\n\
  41. } else {\n\
  42.     set msg \"can't find [info library]/init.tcl; perhaps you need to\\n\"\n\
  43.     append msg \"install Tcl or set your TCL_LIBRARY environment \"\n\
  44.     append msg \"variable?\"\n\
  45.     error $msg\n\
  46. }";
  47.  
  48. /*
  49.  * The following variable is a special hack that allows applications
  50.  * to be linked using the procedure "main" from the Tcl library.  The
  51.  * variable generates a reference to "main", which causes main to
  52.  * be brought in from the library (and all of Tcl with it).
  53.  */
  54.  
  55. extern int main();
  56. int *tclDummyMainPtr = (int *) main;
  57.  
  58. /*
  59.  *----------------------------------------------------------------------
  60.  *
  61.  * Tcl_AppInit --
  62.  *
  63.  *    This procedure performs application-specific initialization.
  64.  *    Most applications, especially those that incorporate additional
  65.  *    packages, will have their own version of this procedure.
  66.  *
  67.  * Results:
  68.  *    Returns a standard Tcl completion code, and leaves an error
  69.  *    message in interp->result if an error occurs.
  70.  *
  71.  * Side effects:
  72.  *    Depends on the startup script.
  73.  *
  74.  *----------------------------------------------------------------------
  75.  */
  76.  
  77. int
  78. Tcl_AppInit(interp)
  79.     Tcl_Interp *interp;        /* Interpreter for application. */
  80. {
  81.     /*
  82.      * Calls to init procedures for various included packages should
  83.      * appear below, if there are any included packages:
  84.      */
  85.  
  86.     /*
  87.      * Execute a start-up script.
  88.      */
  89.  
  90.     return Tcl_Eval(interp, initCmd);
  91. }
  92.